home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / midiin1a / midiecho.frm < prev    next >
Text File  |  1999-10-21  |  4KB  |  159 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Midi Echo"
  4.    ClientHeight    =   4650
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   6480
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4650
  10.    ScaleWidth      =   6480
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.TextBox Text1 
  13.       Height          =   285
  14.       Left            =   2640
  15.       TabIndex        =   7
  16.       Top             =   2400
  17.       Width           =   1215
  18.    End
  19.    Begin VB.ListBox List3 
  20.       Height          =   1425
  21.       ItemData        =   "Midiecho.frx":0000
  22.       Left            =   3360
  23.       List            =   "Midiecho.frx":0002
  24.       TabIndex        =   4
  25.       Top             =   360
  26.       Width           =   2895
  27.    End
  28.    Begin VB.ListBox List2 
  29.       Height          =   1425
  30.       ItemData        =   "Midiecho.frx":0004
  31.       Left            =   240
  32.       List            =   "Midiecho.frx":0006
  33.       TabIndex        =   3
  34.       Top             =   360
  35.       Width           =   2895
  36.    End
  37.    Begin VB.CommandButton Command3 
  38.       Caption         =   "Exit"
  39.       Height          =   495
  40.       Left            =   240
  41.       TabIndex        =   2
  42.       Top             =   3960
  43.       Width           =   6015
  44.    End
  45.    Begin VB.CommandButton Command2 
  46.       Caption         =   "Stop Recording"
  47.       Height          =   495
  48.       Left            =   3360
  49.       TabIndex        =   1
  50.       Top             =   3360
  51.       Width           =   2895
  52.    End
  53.    Begin VB.CommandButton Command1 
  54.       Caption         =   "Start Recording"
  55.       Height          =   495
  56.       Left            =   240
  57.       TabIndex        =   0
  58.       Top             =   3360
  59.       Width           =   3015
  60.    End
  61.    Begin VB.Label Label3 
  62.       Caption         =   "Data passed:"
  63.       Height          =   255
  64.       Left            =   1440
  65.       TabIndex        =   8
  66.       Top             =   2520
  67.       Width           =   975
  68.    End
  69.    Begin VB.Label Label2 
  70.       Caption         =   "Select Output Device"
  71.       Height          =   255
  72.       Left            =   3360
  73.       TabIndex        =   6
  74.       Top             =   120
  75.       Width           =   2055
  76.    End
  77.    Begin VB.Label Label1 
  78.       Caption         =   "Select Input Device"
  79.       Height          =   255
  80.       Left            =   240
  81.       TabIndex        =   5
  82.       Top             =   120
  83.       Width           =   2055
  84.    End
  85. End
  86. Attribute VB_Name = "Form1"
  87. Attribute VB_GlobalNameSpace = False
  88. Attribute VB_Creatable = False
  89. Attribute VB_PredeclaredId = True
  90. Attribute VB_Exposed = False
  91. Option Explicit
  92. Dim i As Long
  93. Private Sub Command1_Click()
  94. 'Here, tmp1 is the handle for the MidiIn device
  95. 'and tmp2 is the handle for the MidiOut device
  96. 'First, open the Input device if one is selected
  97. If List2.ListIndex >= 0 Then
  98.    tmp = midiInOpen(tmp1, List2.ListIndex, AddressOf Memorize_Event, 0, CALLBACK_FUNCTION)
  99. Else
  100.    MsgBox "Please select an Input Device"
  101.    Exit Sub
  102. End If
  103. 'Then the output device
  104. If List3.ListIndex >= 0 Then
  105.    tmp = midiOutOpen(tmp2, List3.ListIndex, 0, 0, 0)
  106. Else
  107.    MsgBox "Please select an Output Device"
  108.    midiInClose (tmp1)
  109.    Exit Sub
  110. End If
  111. List2.Enabled = False
  112. List3.Enabled = False
  113. Command1.Enabled = False
  114. Command2.Enabled = True
  115. 'Start the recording. This resets the timer to 0
  116. tmp = midiInStart(tmp1)
  117. End Sub
  118.  
  119. Private Sub Command2_Click()
  120. List2.Enabled = True
  121. List3.Enabled = True
  122. Command2.Enabled = False
  123. Command1.Enabled = True
  124. 'Stop the recording, and close the midi in device
  125. tmp = midiInReset(tmp1)
  126. tmp = midiInStop(tmp1)
  127. tmp = midiInClose(tmp1)
  128. tmp = midiOutClose(tmp2)
  129. End Sub
  130.  
  131. Private Sub Command3_Click()
  132. Visible = False
  133. Unload Me
  134. End
  135. End Sub
  136.  
  137. Private Sub Form_Load()
  138. 'Disable the 'stop recording' button
  139. Command2.Enabled = False
  140. 'Here, first getting the number of midi in devices
  141. tmp = midiInGetNumDevs
  142. tmp1 = tmp
  143. 'Then examining the capabilities of the devices
  144. For i = 0 To tmp1 - 1
  145.    tmp = midiInGetDevCaps(i, oxMIC, Len(oxMIC))
  146.    If tmp <> 0 Then End
  147. List2.AddItem oxMIC.szPname
  148. Next i
  149. tmp = midiOutGetNumDevs
  150. tmp1 = tmp
  151. 'Then examining the capabilities of the devices
  152. For i = 0 To tmp1 - 1
  153.    tmp = midiOutGetDevCaps(i, oxMOC, Len(oxMOC))
  154.    If tmp <> 0 Then End
  155. List3.AddItem oxMOC.szPname
  156. Next i
  157. End Sub
  158.  
  159.